package com.oak.consumer;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

/**
 * com.oak.consumer -> ConsumerController
 *
 * @Author: guoxy
 * @Description:
 * @Date: 2022/5/15
 */
@RestController
public class ConsumerController {

    @Autowired
    private RestTemplate restTemplate;
    private static final String SERVER_URL = "http://provide-server";

    @Autowired
    private OpenFeignService openFeignService;

    /**
     * 调用服务
     *
     * @return
     */
    @GetMapping("/getOrder")
    private String getOrder() {
        return restTemplate.getForObject(SERVER_URL + "/order", String.class);
    }

    /**
     * 使用openfeign调用服务
     *
     * @return
     */
    @GetMapping("/getOrderOpenFeign")
    private String getOrderOpenFeign() {
        return openFeignService.orderServer();
    }
}